<template>
<div>
    <Modal
    v-model="isShow"
    :title="title"
    @on-ok="save">
        <Form :model="form" :label-width="80">
            <Form-item v-for="(item,index) in formConfig" :key="index" :label="item.label">
            <template v-if="item.type=='input'">
            <Input v-model="form[item.vModel]" placeholder="请输入"></Input>
            </template>
            <template v-if="item.type=='select'">
                <Select v-model="form[item.vModel]" placeholder="请选择">
                    <Option v-for="(sitem,sindex) in item.selectList" :key="sindex" :value="sitem[item.selValue]" :label="sitem[item.selLabel]"></Option>
                </Select>
            </template>
            <template v-if="item.vModel=='sex'">
                <Radio-group v-model="form[item.vModel]">
                    <Radio label="0">男</Radio>
                    <Radio label="1">女</Radio>
                </Radio-group>
        </template>
        </Form-item>
    </Form>
    </Modal>
 
</div>
</template>

<script>
export default {
 props:{
     isShow:{
         type:Boolean,
         default:false
     },
     title:{
         type:String,
         default:""
     }
 },
 data(){
     return{
       formConfig:[
           {
               label:"姓名",
               vModel:"name",
               type:"input",
               width:""
           },
            {
               label:"街道",
               vModel:"streetName",
               type:"select",
               width:"",
               selLabel:"label",
               selValue:"value",
                selectList: [
                {
                    value: 'beijing',
                    label: '北京市'
                },
                {
                    value: 'shanghai',
                    label: '上海市'
                 }
              ]
           },
            {
               label:"社区",
               vModel:"communityName",
               type:"select",
               selLabel:"name",
               selValue:"id",
               selectList: [
                   {
                        id: 'beijing',
                        name: '北京市'
                    },
                    {
                        id: 'shanghai',
                        name: '上海市'
                    }
               ],
               width:""
           },
            {
               label:"性别",
               vModel:"sex",
               type:"radio",
               width:""
           }
       ],
       form:{
         name:"",
         sex:"0"
       }
     }
 },
 methods:{
  save(){
      console.log(this.form)
  }
 }
}
</script>
<style></style>